<style>
</style>
<template>
  <list_url ref="list_url" :config="config">
    <template #action="{row}">
      <el-button @click="to_edit(row)" size="small">详情</el-button>
    </template>
  </list_url>
</template>
<script>
import {_config} from "@/js/s94_tool.js";
import s94Mjs from "s94-js";
import {iframe, in_right_admin} from "@/js/tool.js";

export default {
  props: ['__iframe'],
  data(){
    let app = this, btns = {}, is_del = this.$get('is_del');

    let forms_config = {
	  admin_ids: {label:'管理员',name:'where[admin_id][in]',type:'list_ids',no_table:true,config:'admin/index',value:''},
	  path: {label:'操作路径',name:'where[path][like]',type:'text_one',value:''},
    };
    let list_cols = {
	 id:{name:'id', label:'ID', width:'65px', fixed:'left', type: 'hidden', order:true},
	 head_img: {name:'head_img', label:'头像', width:'45px', type:'file_img'},
	 nickname: {name:'nickname', label:'管理员昵称', width: '120px'},
	 path: {name:'path', label:'操作路径', min_width:'120px'},
	 path_alias: {name:'path_alias', label:'操作内容', min_width:'120px'},
	 http_status_code: {name:'http_status_code', label:'状态码', width:'60px'},
	 ip: {name:'ip', label:'IP地址', width:'130px'},
    };
    if (is_del){
      list_cols['delete_time'] = {name:'delete_time', label:'删除时间', width:'165px', type:'datetime'};
    }else {
      list_cols['create_time'] = {name:'create_time', label:'操作时间', width:'165px'};
    }
    list_cols['action'] = {name:'action', label:'操作', width:'80px', type:'action', fixed:'right'};

    return {
      config: {
        api: '/admin/admin_log/'+(is_del?'recycle':'list'),
        title: "管理员日志列表"+(is_del?'(已删除)':''),
        btns: btns,
        forms_config: forms_config,
        list_cols: list_cols,
        resdata: function(list){
          return list;
        },
        limit: 20,
        p: this.$get('p', 1),
      },
    }
  },
  methods: {
    to_edit(row){
      let can_edit = in_right_admin('AdminLog/edit') && ~[0,row.tenant_id].indexOf(_config('this_tenant.id'))
      can_edit = false;
      let param = {
        id: row.id,
      }
      if (!can_edit) param['is_info'] = 1;
      iframe('admin_log/edit?'+s94Mjs.param_encode(param))
    },
  },
  mounted() {
    let app = this;
    if (!this.__iframe) window['app'] = this;

  }
}
</script>
